<template>
  <div class="login-container" v-loading.fullscreen.lock="fullscreenLoading" element-loading-text="拼命加载中">
    remote login...
  </div>
</template>

<script>
import { loginByRemote } from "@/api/login";
import { getToken, setToken, removeToken } from '@/utils/auth'
export default {
  name: "remote",
  data() {
    return {
      fullscreenLoading: true
    };
  },
  methods: {
    async handleLogin() {
      try {
        const result = await loginByRemote();
        console.log(result);
        if (result.status === 200 && result.data.code === 2000) {
          setToken(result.data.token);
          this.$store.commit("SET_TOKEN", result.data.token);
          this.fullscreenLoading = false;
          this.$router.push({ path: "/" });
        } else {
          this.fullscreenLoading = false;
          window.location.href =process.env.REMOTE_LOGIN;
        }
      } catch (err) {
        console.log(err);
      }
    }
  },
  created() {
    this.handleLogin();
  }
};
</script>
